<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/web/header.jsp" %>
<title>Insert title here</title>
</head>
<body>
	<fieldset class="layui-elem-field" style='margin:30px;padding:30px'>
		<legend>系统登录</legend>
		<div class="layui-field-box">
			<form class="layui-form-pane layui-form">
				<div class="layui-form-item">
					<label class="layui-form-label">账户</label>
					<div class="layui-input-inline">
						<input class="layui-input" name="code" type="text" placeholder="请输入账户"
						required lay-verify="required" autocomplete="off">
					</div>
				</div>
				
				<div class="layui-form-item">
					<label class="layui-form-label">密码</label>
					<div class="layui-input-inline">
						<input class="layui-input" name="pass" type="password" placeholder="请输入密码"
						 required lay-verify="required" autocomplete="off" />
					</div>
				</div>
				
				<div class="layui-form-item">
				<label class="layui-form-label">
					<img src="/TestCompany/AuthCodeServlet" onclick='this.src="/TestCompany/AuthCodeServlet?"+Math.random()'/>
				</label>
					<div class="layui-input-inline">
						<input class="layui-input" name="authcode" type="text" placeholder="请输入验证码"
						required lay-verify="required" autocomplete="off">
					</div>
				</div>
				
				<div class="layui-form-item">
					<div class="layui-input-inline">
						<input type="button" value="登录" class="layui-btn" lay-submit lay-filter="login" />
						<input type="reset" value="重置" class="layui-btn layui-btn-primary" />
						
					</div>
					<input type="button" value="跳转注册" class="layui-btn" onclick="toJsp('/web/reg.jsp')"/>
				</div>
				<input type="hidden" name="action" value="login" />
			</form>
		</div>
	</fieldset>
	
	<script type="text/javascript">
/* 		var form = layui.form;
		var $ = layui.jquery;
		var layer = layui.layer;	 */
		
	/* 	form.on('submit(login)',function(data){
			console.log(data.field) // 校验
			$.ajax({
				url:base.app+"/employee",
				type:"post",
				data:data.field,
				dataType:"text",
				success:function(data){
			//		console.log(data)
					if('A'==data){
						layer.msg("验证码错误");
					}else if(1==data){
						layer.msg("登录成功");
					}else if(2==data){
						layer.msg("密码错误");
					}else{
						layer.msg("帐号不存在");
					}
				}
			});
		}) */
		
		formOn('submit(login)','/employee','text',function(data){
			console.log(data)
			if('A'==data){
				layer.msg("验证码错误");
			}else if("1"==data){
				layer.msg("登录成功",{
					icon:1,
					time:2000
				});
				toJsp('/web/page/main.jsp');
			}else if("2"==data){
				layer.msg("密码错误");
			}else{
				layer.msg("帐号不存在");
			}
		})
		
	</script>
</body>
</html>